################################################################################
# Title 	: Summarising COVID-19 literature review database
# Task  	: This is used for generation of basic study level summary 
# Version	: R version 3.6.3 (2020-02-29)
################################################################################
#rm(list=ls())
library(readstata13)
library(tidyverse)

# Set working directory
# setwd(" ") # set path of your working directory for file export

# Read analysis dataset
dat_lab <- read.dta13("2020-05-07_iddo_lsr_covid-19_sr.dta")
length(unique(dat_lab$st_reg_id))

#---------------------------------------
# Unique number of studies included
#---------------------------------------
dat_lab  %>% 
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

#---------------------------------------
# Unique number of studies by country
#---------------------------------------
dat_lab %>% 
	dplyr::group_by(st_ctry_name) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

#------------------------------------------------
# Suppl Table 1: Risk population description
#------------------------------------------------

# Pregnancy status
dat_lab %>% 
	dplyr::group_by(pa_elig_preg_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# Children enrolled
dat_lab %>% 
	dplyr::group_by(pa_elig_age_min <18) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# Patient with Diabetes
dat_lab %>% 
	dplyr::group_by(pa_elig_diab_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# By HIV status
dat_lab %>% 
	dplyr::group_by(pa_elig_hiv_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# By immunocompromised status
dat_lab %>% 
	dplyr::group_by(pa_elig_immu_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# By asthma status
dat_lab %>% 
	dplyr::group_by(pa_elig_asthma_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# Hypertensive status
dat_lab %>% 
	dplyr::group_by(pa_elig_ht_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# Serious heart condition
dat_lab %>% 
	dplyr::group_by(pa_elig_heart_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)

# Obesity status
dat_lab %>% 
	dplyr::group_by(pa_elig_obese_yn) %>%
	dplyr::summarise(
		number_of_trials = length(unique(st_reg_id))
		)
# End

